<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>2.复习扩展运算符</title>
	</head>
	<body>
		<script type="text/javascript" >
			//扩展运算符，用于展开一个数组
			let arr = [1,3,5,7,9]
			console.log(...arr) //1 3 5 7 9

			//扩展运算符，不能直接展开一个对象
			let obj = {a:1,b:2}
			//扩展运算符，可以在一个对象中，展开另一个对象
			let person = {
				name:'张三',
				age:18,
				...obj
			}
			console.log(person)

			//扩展运算符，用在函数接收参数
			function demo(a,b,...args){
				console.log(a,b,args)
			}
			demo(2,4,6,8)

			let arr1 = [1,2,3]
			let arr2 = [7,8,9]
			let arr3 = [...arr1,4,5,6,...arr2]
			console.log(arr3)

			//可以简写
			// let a = '你好啊'
			// let obj0 = {a:a}
			// console.log(obj0)

			let obj0 = {a:'a'}
			console.log(obj0)

		</script>
	</body>
</html>